package kr.mir.util.config;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public abstract class ConfigNode {

	private String type;
	private String name;
	private Map<String, String> value = new HashMap<String, String>();
	private ConfigNode parent;
	
	protected List<ConfigNode> children = new ArrayList<>();
	
	public abstract void add(ConfigNode config);
	public abstract void remove(ConfigNode config);
	
	public String getType() {
		return type;
	}

	public String getName() {
		return name;
	}

	public String getValue(String key) {
		return value.get(key);
	}

	public List<ConfigNode> getChildren() {
		return children;
	}

	public ConfigNode getParent() {
		return parent;
	}
	
	public boolean isChildren() {
		if(children.isEmpty())
			return false;
		else
			return true; 
	}
	
	public boolean isParent() {
		if(parent == null) return false;
		
		return true;
	}

	public void setType(String type) {
		this.type = type;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setValue(String key, String value) {
		this.value.put(key, value);
	}

	public void setParent(ConfigNode parent) {
		this.parent = parent;
	}
}
